<?php
/**
 * Created by PhpStorm.
 * User: yangjiaming
 * Date: 2018/2/5
 * Time: 12:36
 */

namespace Halo\Validator;


class ParamRule
{
    protected static $regex;
    static function validate($value, $type)
    {
        switch ($type) {
            case 'phone':
                static::isPhone();
                break;
            case 'email':
                static::isEmail();
                break;
            default :
                break;
        }
        return preg_match(static::$regex, $value);
    }
    static function isPhone()
    {
        static::$regex = '/^(\+?86)?1[3578]\d{9}$/';
    }
    static function isEmail()
    {
        static::$regex = '/.+@[^@]+\.[^@]*[^\.]$/';
    }
    static function defaultValue()
    {

    }
}